Skip to content

Document OTLP retries with the grpc-java sender - #9075

Open
yangjj-iso wants to merge 2 commits into
open-telemetry:mainfrom
yangjj-iso:fix/8653-document-managed-channel-retries
Open

yangjj-iso wants to merge 2 commits into
open-telemetry:mainfrom
yangjj-iso:fix/8653-document-managed-channel-retries

Conversation

@yangjj-iso

@yangjj-iso yangjj-iso commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Related to #8653.

Document retry behavior in the grpc-managed-channel sender's README. The sender ignores the exporter builder's setRetryPolicy setting. The README explains how to configure or disable retries on a grpc-java ManagedChannel and pass it to the exporter builder with setChannel.

Validation

  • git diff --check passed. The change relative to the PR base consists of the sender README.
  • The README passed a standalone Flexmark 0.64.8 check with the repository's formatter options. The Gradle wrapper could not download its distribution in this environment.

Signed-off-by: redyyang <3202137046@qq.com>
@yangjj-iso
yangjj-iso requested a review from a team as a code owner November 29, 2026 13:51
@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: yangjj-iso / name: redyyang (cefe05d)

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-12-05 01:56 UTC

Merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with the author? Comment /dashboard route:author to route it back.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.52%. Comparing base (a92b644) to head (6d4fc6d).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9075      +/-   ##
============================================
- Coverage     90.56%   90.52%   -0.05%     
- Complexity    11220    11272      +52     
============================================
  Files          1032     1040       +8     
  Lines         30599    30762     +163     
  Branches       4010     4035      +25     
============================================
+ Hits          27711    27846     +135     
- Misses         1913     1931      +18     
- Partials        975      985      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yangjj-iso
yangjj-iso force-pushed the fix/8653-document-managed-channel-retries branch from 5cd0050 to cefe05d Compare November 30, 2026 03:15

@breedx-splk breedx-splk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me, thanks.

*
* <p>The grpc-java sender ({@code opentelemetry-exporter-sender-grpc-managed-channel}) delegates
* retries to its {@link ManagedChannel}, including when it creates a fallback channel. To
* customize retries with this sender, configure a channel and pass it to {@link #setChannel}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing javadoc. Reading quickly you might conclude that RetryPolicy is applied the underlying ManagedChannel. But that's not what happens. None of your retry config (and barely any config at all) stands to impact the behavior of upstream grpc sender:

@Override
public GrpcSender createSender(GrpcSenderConfig grpcSenderConfig) {
checkState(
grpcSenderConfig instanceof ExtendedGrpcSenderConfig,
"grpcSenderConfig must be an instance of ExtendedGrpcSenderConfig for UpstreamGrpcSenderProvider");
ExtendedGrpcSenderConfig extendedSenderConfig = (ExtendedGrpcSenderConfig) grpcSenderConfig;
boolean shutdownChannel = false;
Object configManagedChannel = extendedSenderConfig.getManagedChannel();
ManagedChannel managedChannel;
if (configManagedChannel != null) {
checkState(
configManagedChannel instanceof ManagedChannel,
"managedChannel must be an instance of ManagedChannel for UpstreamGrpcSenderProvider");
managedChannel = (ManagedChannel) configManagedChannel;
} else {
// Shutdown the channel as part of the exporter shutdown sequence if we created it.
shutdownChannel = true;
managedChannel = minimalFallbackManagedChannel(grpcSenderConfig.getEndpoint());
}
return new UpstreamGrpcSender(
managedChannel,
extendedSenderConfig.getFullMethodName(),
extendedSenderConfig.getCompressor(),
shutdownChannel,
extendedSenderConfig.getTimeout(),
extendedSenderConfig.getHeadersSupplier(),
extendedSenderConfig.getExecutorService());
}
/**
* If {@link ManagedChannel} is not explicitly set, provide a minimally configured fallback
* channel to avoid failing initialization.
*
* <p>This is required to accommodate autoconfigure with {@code
* opentelemetry-exporter-sender-grpc-managed-channel} which will always fail to initialize
* without a fallback channel since there isn't an opportunity to explicitly set the channel.
*
* <p>This only incorporates the target address, port, and whether to use plain text. All
* additional settings are intentionally ignored and must be configured with an explicitly set
* {@link ManagedChannel}.
*/
private static ManagedChannel minimalFallbackManagedChannel(URI endpoint) {
// grpc-java parses host names with java.net.URI, which returns null for some valid DNS names
// (JDK-8188305) that EndpointUtil accepts, so fail with a clear message. Filed upstream as
// https://github.com/grpc/grpc-java/issues/13075; this check can be relaxed if grpc-java
// fixes host validation on their side.
if (endpoint.getHost() == null) {
throw new IllegalArgumentException(
"Invalid endpoint, host not supported by grpc-java: "
+ endpoint
+ ". java.net.URI cannot parse host names whose last label starts with a digit."
+ " Use the OkHttp sender or a fully qualified host name.");
}
ManagedChannelBuilder<?> channelBuilder =
ManagedChannelBuilder.forAddress(endpoint.getHost(), endpoint.getPort());
if (!endpoint.getScheme().equals("https")) {
channelBuilder.usePlaintext();
}
return channelBuilder.build();
}

Also, I don't like the precedent of including sender specific details in the documentation. In general, all the senders should should conform to all the configuration of the builders. Any divergence from this should be called out clearly in the sender's docs - its not the builder's responsibility to communicate all the nuances of all the senders.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @jack-berg. I moved the retry guidance to the sender module README in 6d4fc6d and restored the three exporter builder Javadocs. The README now explains that the sender ignores setRetryPolicy and that the ManagedChannel controls retry behavior. Could you take another look?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants